<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增疾病管理')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>

</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-disease-add">
        <ul class="nav nav-tabs">
            <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true"> 基本信息</a>
            </li>
            <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">药品TDK</a>
            </li>
            <li class=""><a data-toggle="tab" href="#tab-3" aria-expanded="false">临床招募TDK</a>
            </li>
        </ul>
        <div class="tab-content">
            <div id="tab-1" class="tab-pane active" style="padding: 20px">
                <div class="form-group">
                    <label class="col-sm-3 control-label ">父级科目</label>
                    <div class="col-sm-8">
                        <div class="input-group">
                            <input id="treeId" name="pid" type="hidden" th:value="${disease?.id}"/>
                            <input class="form-control" placeholder="请选择父级疾病" type="text" onclick="selectDiseaseTree()" id="treeName" readonly="true" th:value="${disease?.name}">
                            <span class="input-group-addon"><i class="fa fa-search"></i></span>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">疾病名称</label>
                    <div class="col-sm-8">
                        <input name="name" id="name" class="form-control" placeholder="请输入名称" type="text" required>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">排序</label>
                    <div class="col-sm-8">
                        <input name="sortid" class="form-control" placeholder="请输入排序数字" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">加群二维码</label>
                    <div class="col-sm-8">
                        <input type="hidden" name="iconpath">
                        <div class="file-loading">
                            <input class="form-control file-upload" id="iconpath" name="file" type="file">
                        </div>
                    </div>
                </div>
            </div>
            <div id="tab-2" class="tab-pane" style="padding: 20px">
                <div class="form-group">
                    <label class="col-sm-3 control-label">药品标题</label>
                    <div class="col-sm-8">
                        <input name="drugT" class="form-control" placeholder="请输入标题" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">药品关键词</label>
                    <div class="col-sm-8">
                        <input name="drugK" class="form-control" placeholder="请输入关键词" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">药品描述</label>
                    <div class="col-sm-8">
                        <textarea name="drugD" class="form-control" placeholder="请输入描述" type="text">
                        </textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">药品内容:</label>
                    <div class="col-sm-8">
                        <input type="hidden" class="form-control" required>
                        <script id="drugDescribe" name="drugDescribe" type="text/plain"></script>
                    </div>
                </div>
            </div>
            <div id="tab-3" class="tab-pane" style="padding: 20px">
                <div class="form-group">
                    <label class="col-sm-3 control-label">临床标题</label>
                    <div class="col-sm-8">
                        <input name="lcT" class="form-control" placeholder="请输入标题" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">临床关键词</label>
                    <div class="col-sm-8">
                        <input name="lcK" class="form-control" placeholder="请输入关键词" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">临床描述</label>
                    <div class="col-sm-8">
                        <textarea name="lcD" class="form-control" placeholder="请输入描述" type="text">
                        </textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">临床内容:</label>
                    <div class="col-sm-8">
                        <input type="hidden" class="form-control" required>
                        <script id="lcDescribe" name="lcDescribe" type="text/plain"></script>
                    </div>
                </div>
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script src="/ueditor/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
<script src="/ueditor/ueditor.all.js" type="text/javascript" charset="utf-8"></script>
<script src="/ueditor/lang/zh-cn/zh-cn.js" type="text/javascript" charset="utf-8"></script>
<script th:inline="javascript">
    var prefix = ctx + "new/disease"
    $("#form-disease-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            if('' == $('#name').val()){
                $.modal.alertError("请填写【基本信息】中的疾病名称！");
                return
            }
            $.operate.save(prefix + "/add", $('#form-disease-add').serialize());
        }
    }

    $(".file-upload").fileinput({
        uploadUrl: ctx + 'common/upload',
        maxFileCount: 1,
        autoReplace: true
    }).on('fileuploaded', function (event, data, previewId, index) {
        $("input[name='" + event.currentTarget.id + "']").val(data.response.fileName)
    }).on('fileremoved', function (event, id, index) {
        $("input[name='" + event.currentTarget.id + "']").val('')
    })

    /*疾病管理-新增-选择父疾病管理树*/
    function selectDiseaseTree() {
        var options = {
            title: '疾病管理选择',
            width: "480",
            url: prefix + "/selectDiseaseTree/" + $("#treeId").val(),
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero){
        var body = $.modal.getChildFrame(index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        $.modal.close(index);
    }

    //富文本
    UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
    UE.Editor.prototype.getActionUrl = function (action) {
        if (action == 'uploadimage' || action == 'uploadscrawl') {
            return '/common/upload';
        } else {
            return this._bkGetActionUrl.call(this, action);
        }
    }
    var ue = UE.getEditor('drugDescribe', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })

    var ue = UE.getEditor('lcDescribe', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })
</script>
</body>
</html>